<template>
  <div class="xlyz">
    <div class="xiangqing-header">
      <img @click="Back()" class="back" src="../../assets/img/shouye/header-xinpin/back.png" />
      <p>奶粉</p>
      <img @click="fenxiang()" class="share" src="../../assets/img/shouye/header-xinpin/share.png" />
    </div>
    <img src="../../assets/img/shouye/shouye-muying/haibao_mamibaobei.png" alt="">
    <div class="naifen-jieshao">
        该模块主要内容是奶粉品牌的介绍，成立于1924年，
        是日本零食十强之一。制作的曲奇和糕点系列，品质
        远胜于欧洲传统西点，做工研究、精致、高贵、时尚、
        健康是Bourbon一贯的严谨作风，其北日本系列礼盒
        更是夺得了销售冠军，相当受欢迎。
    </div>
    <ul>
      <li>
        <ul class="goods">
          <li>
            <ul class="goods-list">
              <li v-for="good in Arr">
                <div>
                    <router-link :to="{name: 'shangpinxiangqing', params: {good}}">
                    <img :src="good.src"/>
                    </router-link></div>
                <h3>{{good.name}}</h3>
                <h4>￥{{good.price}}</h4>
                <h5>立即购买</h5>
              </li>
            </ul>
          </li>
        </ul>
      </li>
    </ul>
    <div class="fenxiang-mengban" v-if="isFX">
      <div class="fenxiang">
        <ul>
          <li>
            <ul class="fenxiang-list">
              <li>
                <div>
                  <img src="../../assets/img/shouye/fenxiang/pengyouquan.png"/>
                </div>
                <p>微信朋友圈</p>
              </li>
              <li>
                <div>
                  <img src="../../assets/img/shouye/fenxiang/weixin.png" /></div>
                <p>微信好友</p>
              </li>
              <li>
                <div>
                  <img src="../../assets/img/shouye/fenxiang/QQ.png"/></div>
                <p>QQ好友</p>
              </li>
            </ul>
          </li>
          <li>
            <ul class="fenxiang-list">
              <li>
                <div>
                  <img src="../../assets/img/shouye/fenxiang/QQkongjian.png"/></div>
                <p>QQ空间</p>
              </li>
              <li>
                <div>
                  <img src="../../assets/img/shouye/fenxiang/weibo.png" /></div>
                <p>微博</p>
              </li>
              <li>
                <div>
                  <img src="../../assets/img/shouye/fenxiang/fuzhilianjie.png"/></div>
                <p>复制链接</p>
              </li>
            </ul>
          </li>
        </ul>
        <div @click="quxiao()">
          取消
        </div>
      </div>
    </div>
    <div class="up" @click="toTop()" v-if="isUP">
      <img src="../../assets/img/shouye/tuijian-xuanliyanzhuang/toTop.png"/>
    </div>
  </div>
</template>
<script>
  import Vue from 'vue'
  export default {
    data () {
      return {
        isFX: false,
        isUP: false,
        Arr: [],
        arr: [],
        zArr: []
      }
    },
    methods: {
      Back () {
        this.$router.go(-1)
      },
      fenxiang () {
        this.isFX = true
      },
      quxiao () {
        this.isFX = false
      },
      toTop () {
        if(document.documentElement){
          document.documentElement.scrollTop = 0;
        }else{
          document.body.scrollTop = 0;
        }
      },
      menu() {
        this.scroll = document.documentElement.scrollTop || document.body.scrollTop;
        if(this.scroll > 0){
          //显示 a 标签
          this.isUP = true;
        }else{
          //隐藏 a 标签
          this.isUP = false;
        }
      },
      top () {
        window.scrollTo(0,0)
      },
      tuijianGet() {
        //  发起get请求
        //  设置代理服务器转发的域
        Vue.axios.get('/api/get', {
//              get传递的query参数
//            params: {
//              name: 'along',
//              age: 32
//            }
        }).then( (response) => {
          //  成功之后的回调
//          console.log(response.data);
          this.arr = response.data;
//          console.log(this.arr);
          for (let i = 0 ; i < this.arr.length; i ++) {
            if (this.arr[i].sc === '奶粉') {
              this.Arr.push(this.arr[i]);
//              console.log(this.Arr);
            }
          }
//          console.log(this.Arr);
        }).catch( (error) => {
          //  请求出错的处理
          console.log(error)
        });
      }
    },
    mounted() {
      window.addEventListener('scroll', this.menu);
      this.tuijianGet();
    },
    created () {
      this.top();
    }
  }
</script>
<style scoped>
  .xlyz {
    position: relative;
    width: 100%;
    padding-top: 2rem;
    background: #f2f2f2;
  }
  .xiangqing-header {
    width: 100%;
    height: 2rem;
    line-height: 2rem;
    background: #e53e42;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10;
  }
  .back {
    vertical-align: middle;
    width: 0.6rem;
    margin-left: 0.5rem;
  }
  .xiangqing-header>p{
    width: 12.5rem;
    height: 100%;
    text-align: center;
    display: inline-block;
    font-family: MicrosoftYaHei;
    font-size: 0.7rem;
    font-weight: normal;
    font-stretch: normal;
    color: #ffffff;
  }
  .share {
    vertical-align: middle;
    width: 1rem;
  }
  .xlyz>img{
    width: 100%;
    font-size: 0;
  }
  .naifen-jieshao {
    font-family: MicrosoftYaHei;
    font-size: 0.7rem;
    font-weight: normal;
    color: #4d4d4d;
    padding: 0.5rem;
    background: #e2f6fe;
  }
  .goods-list {
  }
  .goods-list li {
    display: inline-block;
    text-align: center;
    border: 1px solid #ccc;
    margin: 0.5rem;
    background: #fff;
  }
  .goods-list div {
    width: 4.85rem;
    /*background: red;*/
    margin: 0 auto;
    padding: 1rem;
    border-bottom: 1px solid #ccc;
  }
  .goods-list img {
    width: 60%;
  }
  .goods-list h3 {
    font-family: SimHei;
    font-size: 0.6rem;
    font-weight: normal;
    font-stretch: normal;
    color: #4d4d4d;
    margin-top: 0.2rem;
  }
  .goods-list h4 {
    font-family: MicrosoftYaHei;
    font-size: 0.6rem;
    font-weight: normal;
    font-stretch: normal;
    color: #e53e42;
  }
  .goods-list h5 {
    font-family: MicrosoftYaHei;
    font-size: 0.5rem;
    font-weight: normal;
    font-stretch: normal;
    color: #ffffff;
    background-color: #e53e42;
    border-radius: 0.5rem;
    width: 4rem;
    padding: 0.1rem;
    margin: 0 auto;
    margin-bottom: 0.2rem;
  }
  .fenxiang-mengban {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    background: rgba(0,0,0,0.5);
  }
  .fenxiang {
    padding-top: 1rem;
    background: #fff;
    width: 100%;
    height: 10rem;
    position: absolute;
    bottom: 0;
    left: 0;
  }
  .fenxiang-list {
    display: flex;
  }
  .fenxiang-list li {
    flex: 1;
    text-align: center;
  }
  .fenxiang-list div {
    width: 1.5rem;
    height: 1.5rem;
    margin: 0.5rem auto;
  }
  .fenxiang-list div img {
    width: 100%;
  }
  .fenxiang-list p {
    font-size: 0.6rem;
    font-weight: normal;
    font-stretch: normal;
    color: #4d4d4d;
  }
  .fenxiang>div {
    font-size: 0.6rem;
    font-weight: normal;
    font-stretch: normal;
    background: #e53e42;
    color: #fff;
    width: 3rem;
    text-align: center;
    padding: 0.2rem;
    border-radius: 0.2rem;
    margin: 0.5rem auto;
  }
  .up {
    width: 1.5rem;
    position: fixed;
    bottom: 0;
    right: 0.3rem;
  }
  .up img {
    width: 100%;
  }
</style>
